﻿using System;
using System.Diagnostics;
using System.Windows;

namespace 享元模式_围棋例子
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    /// 
    /// Flyweight(抽象享元类)
    /// ConcreteFlyweight(具体享元类)
    /// UnsharedConcreteFlyweight(非共享 具体享元类)
    /// FlyweightFactory(享元工厂类)
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            IgoChessman black1, black2, black3, white1, white2;
            var factory = IgoChessmanFactory.Default;
            //通过享元工厂获取3颗黑子
            black1 = factory.GetIgoChessman("b");
            black2 = factory.GetIgoChessman("b");
            black3 = factory.GetIgoChessman("b");
            Debug.WriteLine("判断两颗黑子是否相同：" + (black1 == black2));

            white1 = factory.GetIgoChessman("w");
            white2 = factory.GetIgoChessman("w");
            Debug.WriteLine("判断两颗白子是否相同：" + (white1 == white2));

            //显示棋子
            black1.Display(new Coordiantes(1, 2));
            black2.Display(new Coordiantes(3, 4));
            black3.Display(new Coordiantes(1, 3));

            white1.Display(new Coordiantes(2, 5));
            white2.Display(new Coordiantes(2, 4));
            


        }
    }
}
